//
//  BeautyLightTabbarViewController.m
//  ForYourBeauty
//
//  Created by Kelly xu on 2019/5/21.
//  Copyright © 2019 changrenTech. All rights reserved.
//

#import "BeautyLightTabbarViewController.h"
#import "FinderHomeViewController.h"
#import "BeautyLightHomeViewController.h"
#import "MyCenterViewController.h"
@interface BeautyLightTabbarViewController (){
    
}
@property(nonatomic,weak)IBOutlet UIImageView *tabbarImgView;
@property(nonatomic,weak)IBOutlet UIButton *finderBtnN;
@property(nonatomic,weak)IBOutlet UIButton *finderBtnH;
@property(nonatomic,weak)IBOutlet UIButton *beautyBtnN;
@property(nonatomic,weak)IBOutlet UIButton *beautyBtnH;
@property(nonatomic,weak)IBOutlet UIButton *myCenterBtnN;
@property(nonatomic,weak)IBOutlet UIButton *myCenterBtnH;
@property(nonatomic,weak)IBOutlet UIView *contentView;
@property(nonatomic,strong)FinderHomeViewController *firstViewController;
@property(nonatomic,strong)BeautyLightHomeViewController *secondViewController;
@property(nonatomic,strong)MyCenterViewController *thirdViewController;
@end

@implementation BeautyLightTabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationController.navigationBarHidden = YES;
    [self.contentView addSubview:self.firstViewController.view];
    [self addChildViewController:self.firstViewController];
}
-(IBAction)tabbarSelect:(id)sender{
    if ([sender isEqual:self.finderBtnN]) {
        self.finderBtnH.hidden = NO;
        self.finderBtnN.hidden = YES;
        self.beautyBtnH.hidden = YES;
        self.beautyBtnN.hidden = NO;
        self.myCenterBtnH.hidden = YES;
        self.myCenterBtnN.hidden = NO;
        [self.tabbarImgView setImage:[UIImage imageNamed:@"tabbarBg1"]];
        [self.contentView removeAllSubviews];
        [self.contentView addSubview:self.firstViewController.view];
        [self addChildViewController:self.firstViewController];
    }else if ([sender isEqual:self.beautyBtnN]) {
        self.finderBtnH.hidden = YES;
        self.finderBtnN.hidden = NO;
        self.beautyBtnH.hidden = NO;
        self.beautyBtnN.hidden = YES;
        self.myCenterBtnH.hidden = YES;
        self.myCenterBtnN.hidden = NO;
        [self.tabbarImgView setImage:[UIImage imageNamed:@"tabbarBg2"]];
        [self.contentView removeAllSubviews];
        [self.contentView addSubview:self.secondViewController.view];
        [self addChildViewController:self.secondViewController];
    }else if ([sender isEqual:self.myCenterBtnN]) {
        self.finderBtnH.hidden = YES;
        self.finderBtnN.hidden = NO;
        self.beautyBtnH.hidden = YES;
        self.beautyBtnN.hidden = NO;
        self.myCenterBtnH.hidden = NO;
        self.myCenterBtnN.hidden = YES;
        [self.tabbarImgView setImage:[UIImage imageNamed:@"tabbarBg3"]];
        [self.contentView removeAllSubviews];
        [self.contentView addSubview:self.thirdViewController.view];
        [self addChildViewController:self.thirdViewController];
    }
}
#pragma mark - instance
-(FinderHomeViewController*)firstViewController{
    if (!_firstViewController) {
        _firstViewController = [[FinderHomeViewController alloc]init];
        _firstViewController.view.frame = CGRectMake(0, 0, self.contentView.width, self.contentView.height);
    }
    return _firstViewController;
}
-(BeautyLightHomeViewController*)secondViewController{
    if (!_secondViewController) {
        _secondViewController = [[BeautyLightHomeViewController alloc]init];
        _secondViewController.view.frame = CGRectMake(0, 0, self.contentView.width, self.contentView.height);
    }
    return _secondViewController;
}
-(MyCenterViewController*)thirdViewController{
    if (!_thirdViewController) {
        _thirdViewController = [[MyCenterViewController alloc]init];
        _thirdViewController.view.frame = CGRectMake(0, 0, self.contentView.width, self.contentView.height);
    }
    return _thirdViewController;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
